<template>
  <div class="machine-list">
    <van-nav-bar
        left-arrow
        @click-left="onClickLeft"
        title="设备详情"
    />
    <div class="table-container">
      <div>
        <div class="list-item">
          <div class="list-item-main-text">
            <van-row>
              <van-col span="24">
                <div>
                  <div class="item-text">
                    <div>
                      <span>{{ obj.id }}</span> <span style="margin-left: 10px;">{{ obj.name }}</span>
                    </div>
                  </div>
                  <div class="item-text">
                    <div>
                      {{ obj.address }}
                    </div>
                  </div>
                </div>
              </van-col>
            </van-row>
          </div>
        </div>
      </div>
      <div>
        <van-cell title="选择资质" is-link @click="goQuaList" class="vanCell"/>
      </div>
      <div>
        <van-cell title="巡检滤芯更换" is-link @click="goPatrol" class="vanCell"/>
      </div>
      <div>
        <van-cell title="水电费管理" is-link @click="goCost" class="vanCell"/>
      </div>
      <div>
        <van-cell title="合同管理" is-link @click="goContract" class="vanCell"/>
      </div>
      <div>
        <van-cell title="设备信息" is-link @click="goMachineEdit" class="vanCell"/>
      </div>
      <div>
        <van-cell title="资质预览" is-link @click="goPreviewQua" class="vanCell"/>
      </div>
      <div>
        <van-cell title="二维码下载" is-link @click="goPreviewQuaQRCode" class="vanCell"/>
      </div>
    </div>
  </div>
</template>

<script>
import {machineGet} from "@/api/operator";

export default {
  data() {
    return {
      loading: false,
      obj: {
        id: '',
        name: '',
        address: ''
      }
    };
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1)
    },
    getObj() {
      let params = {
        id: this.$route.query.id
      }
      machineGet(params).then(res => {
        this.obj.id = res.data.id
        this.obj.name = res.data.name
        this.obj.address = res.data.address
      })
      this.loading = false
    },
    goQuaList() {
      this.$router.push({
        path: '/operator/machine/quaList',
        query: {
          id: this.obj.id
        }
      })
    },
    goPatrol() {
      this.$router.push({
        path: '/operator/machine/patrol',
        query: {
          id: this.obj.id
        }
      })
    },
    goCost() {
      this.$router.push({
        path: '/operator/machine/costList',
        query: {
          id: this.obj.id
        }
      })
    },
    goContract() {
      this.$router.push({
        path: '/operator/machine/contract',
        query: {
          id: this.obj.id
        }
      })
    },
    goMachineEdit() {
      this.$router.push({
        path: '/operator/machine/info',
        query: {
          id: this.obj.id
        }
      })
    },
    goPreviewQua() {
      this.$router.push({
        path: '/operator/machine/quaPreview',
        query: {
          id: this.obj.id
        }
      })
    },
    goPreviewQuaQRCode(){
      this.$router.push({
        path: '/operator/machine/previewQuaQRCode',
        query: {
          id: this.obj.id
        }
      })
    }
  },
  mounted() {
    this.getObj()
  }
};
</script>

<style lang="less" scoped>
.machine-list {
  min-height: 80vh;
  background: #f7f8fa;
  padding-bottom: 100px;
  padding-top: 50px;

  .van-nav-bar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 99;
    width: 100%;
    //background: #1e98dc;

    .van-nav-bar__title,
    .van-nav-bar__text,
    .van-icon-arrow-left {
      color: #fff;
    }
  }

  .top-btn {
    width: 100%;
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 10;
    background: #fff;
    border-top: 1px solid #ddd;
    padding: 10px 0;

    .van-button {
      width: 90%;
      margin: 0 auto;
    }
  }

  .table-main {
    border-top: 1px #efefef solid;
  }

  .list-item {
    margin-top: 10px;

    .titlename {
      font-size: 18px;
    }

    .van-collapse-item__content {
      background: #efefef;
    }

    .van-collapse-item__title--expanded {
      box-shadow: 0 5px 5px rgba(126, 126, 126, 0.1);
    }

    .title-cell {
      border-bottom: 1px solid #ebedf0;
      white-space: nowrap;

      &::after {
        border: none;
      }
    }

    .van-collapse-item--border::after {
      border: none;
    }

    .list-item-main-text {
      background: #fff;
      padding: 10px 15px;
      font-size: 14px;

      .item-text {
        padding: 3px 5px 3px 20%;
        display: flex;

      }

      .item-text-go-detail {
        .go-detail {
          margin: auto;
          padding: 12px;
        }
      }
    }
  }

  .list-item-btnbox {
    border-top: solid 1px #ebedf0;
    border-bottom: solid 1px #ebedf0;
    background: #fff;
    padding: 0 5px;
    height: 32px;

    .list-item-btnmain1 {
      float: left;

      .van-button {
        padding: 5px 5px;
        margin-left: 5px;
        min-width: 60px;
        font-size: 13px;
      }
    }

    .list-item-btnmain2 {
      float: right;

      .van-button {
        padding: 5px 5px;
        margin-left: 5px;
        min-width: 60px;
        font-size: 13px;
      }
    }
  }

  .clear {
    clear: both;
  }

}

.van-button--small {
  height: 20px;
}

.delete-button {
  height: 100%;
}

.vanCell {
  background-color: #c4d4f4;
  //font-weight: bold;
  margin-top: 20px;
  margin-left: 5%;
  border-radius: 20px;
  width: 90%;
}
</style>
